package com.lanou.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lanou.entity.ClassQaQuestion;
import com.lanou.mapper.ClassQaQuestionMapper;
import com.lanou.service.ClassQaQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName ClassQaQuestionServiceImpl
 * @Description TODO
 * @Author cuiruitong
 * @Date 2025年08月14日 19:43
 * @Version 1.0
 */
@Service
public class ClassQaQuestionServiceImpl implements ClassQaQuestionService {
    @Autowired
    private ClassQaQuestionMapper classQaQuestionMapper;
    @Override
    public int addClassQaQuestion(ClassQaQuestion classQaQuestion) {
        return classQaQuestionMapper.addClassQaQuestion(classQaQuestion);
    }

    @Override
    public PageInfo<ClassQaQuestion> selectQuestionsWithAnswers(Integer courseId,String orderRule,int pageNum,int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<ClassQaQuestion> classQaQuestions = classQaQuestionMapper.selectQuestionsWithAnswers(courseId,orderRule);
        PageInfo<ClassQaQuestion> pageInfo = new PageInfo<>(classQaQuestions);
        return pageInfo;
    }

    @Override
    public ClassQaQuestion getQuestionById(Integer id) {
        ClassQaQuestion question = classQaQuestionMapper.getQuestionById(id);
        return question;
    }
}
